package com.chookss.home.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chookss.R;
import com.chookss.Urls;
import com.chookss.WebCommonActivity;
import com.chookss.base.BaseViewHolderEx;
import com.chookss.base.StaticClass;
import com.chookss.home.NavigationBaseActivity;
import com.chookss.home.audit.PaySlipActivity;
import com.chookss.home.audit.WorkCardActivity;
import com.chookss.home.audit.clockIn.ClockInAskHolidayActivity;
import com.chookss.home.audit.clockIn.ClockInHomeActivity;
import com.chookss.home.audit.overtime.OvertimeActivity;
import com.chookss.home.audit.project.ProjectManagementActivity;
import com.chookss.home.audit.reimbursement.ReimbursementActivity;
import com.chookss.home.audit.resign.ResignHomeActivity;
import com.chookss.home.audit.seal.SealHomeActivity;
import com.chookss.home.audit.shop.ShopActivity;
import com.chookss.home.audit.upgrade.UpgradeHomeActivity;
import com.chookss.home.entity.NavigationEntity;
import com.chookss.home.inspection.InspectionHomeActivity;
import com.chookss.home.interview.InterviewRecordsActivity;
import com.chookss.home.other.MoreFunctionActivity;
import com.chookss.home.running.RunningHomeActivity;
import com.chookss.tools.GlideUtils;
import com.chookss.tools.NavigationTools;
import com.chookss.video.VideoBaseActivity;
import com.chookss.view.NumImageView;
import com.johnrambo.ktea.ktExtends.ShareUtils;

import java.util.ArrayList;

public class NavigationAdapter extends BaseQuickAdapter<NavigationEntity, BaseViewHolderEx> {
    private Context mContext;
    private int index = 0;
    private int num = 0;
    private int type = 0;//0是正常模式展示 1代表第8个要展示更多
    private ArrayList<NavigationEntity> data;
    public NavigationAdapter(int layoutResId, Context context, @io.reactivex.annotations.Nullable ArrayList<NavigationEntity> data) {
        super(layoutResId, data);
        this.mContext = context;
    }

    @Override
    protected void convert(BaseViewHolderEx helper, NavigationEntity entity) {
        NumImageView numImgaeView = helper.getView(R.id.numImgaeView);
        TextView tvNavigation = helper.getView(R.id.tvNavigation);

        if (type == 1 && helper.getItemPosition() == 7) {
            tvNavigation.setText("更多");
            Glide.with(mContext).load(R.drawable.icon_more).into(numImgaeView);
        } else {
            tvNavigation.setText(entity.getNavigationName());
            GlideUtils.load(mContext, entity.getNavigationImg(), numImgaeView, R.drawable.default_news);
            if (!"01".equals(entity.getNavigationCode())) {
                numImgaeView.setNum(0);
            } else {
                index = helper.getItemPosition();
                numImgaeView.setNum(num);
            }
        }
        helper.getItemView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 01公告 02 日志 03资料 04学习计划05考试 06 面试 07 通讯录 08  个人能力09 我的待办10 发布视频11 发布新闻12发布日志13题库14视频15溯源
                //    16图文发布17图文18邀请注册19 小视频  20 面试评价 21写日报  22写周报 23写月报24知识库
                Intent intent = null;
                if ("更多".equals(tvNavigation.getText().toString())) {
                    intent = new Intent(mContext, MoreFunctionActivity.class);
                    mContext.startActivity(intent);
                } else {
                    if ("01".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 1);
                        mContext.startActivity(intent);
                    } else if ("02".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 2);
                        mContext.startActivity(intent);
                    } else if ("03".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 3);
                        mContext.startActivity(intent);
                    } else if ("04".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 4);
                        mContext.startActivity(intent);
                    } else if ("05".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 5);
                        mContext.startActivity(intent);
                    } else if ("06".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 6);
                        mContext.startActivity(intent);
                    } else if ("07".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 7);
                        mContext.startActivity(intent);
                    } else if ("08".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, WebCommonActivity.class);
                        String url = NavigationTools.getAllUrl2(mContext, Urls.getCapacityAnalysisCapacity) + "&employeeCode=" + new ShareUtils().getString(mContext, StaticClass.EMPLOYEECODE, "");
                        if (url != null) {
                            intent.putExtra("url", url);
                            intent.putExtra("isPersonalAbility", true);
                            intent.putExtra("title", "个人能力分析");
                            mContext.startActivity(intent);
                        }
                    } else if ("13".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 0);
                        mContext.startActivity(intent);
                    } else if ("14".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, VideoBaseActivity.class);
                        mContext.startActivity(intent);
                    }else if ("15".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 15);
                        mContext.startActivity(intent);
                    }else if ("17".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 17);
                        mContext.startActivity(intent);
                    }else if ("19".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, VideoBaseActivity.class);
                        intent.putExtra("index", 1);
                        mContext.startActivity(intent);
                    }else if ("20".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, InterviewRecordsActivity.class);
                        intent.putExtra("type", 2);
                        mContext.startActivity(intent);
                    }else if ("24".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 24);
                        mContext.startActivity(intent);
                    }else if ("26".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, NavigationBaseActivity.class);
                        intent.putExtra("type", 26);
                        mContext.startActivity(intent);
                    }else if ("27".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, ClockInHomeActivity.class);
                        mContext.startActivity(intent);
                    }else if ("28".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, ClockInAskHolidayActivity.class);
                        mContext.startActivity(intent);
                    }else if ("29".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, WorkCardActivity.class);
                        mContext.startActivity(intent);
                    }else if ("30".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, ReimbursementActivity.class);
                        mContext.startActivity(intent);
                    }else if ("31".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, ShopActivity.class);
                        mContext.startActivity(intent);
                    }else if ("32".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, ReimbursementActivity.class);
                        intent.putExtra("type",9);
                        mContext.startActivity(intent);
                    }else if ("33".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, ReimbursementActivity.class);
                        intent.putExtra("type",10);
                        mContext.startActivity(intent);
                    }else if ("34".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, RunningHomeActivity.class);
                        mContext.startActivity(intent);
                    }else if ("35".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, SealHomeActivity.class);
                        mContext.startActivity(intent);
                    }else if ("36".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, InspectionHomeActivity.class);
                        mContext.startActivity(intent);
                    }else if ("37".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, PaySlipActivity.class);
                        mContext.startActivity(intent);
                    }else if ("38".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, ResignHomeActivity.class);
                        mContext.startActivity(intent);
                    }else if ("39".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, UpgradeHomeActivity.class);
                        mContext.startActivity(intent);
                    }else if ("40".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, ProjectManagementActivity.class);
                        mContext.startActivity(intent);
                    }else if("41".equals(entity.getNavigationCode())) {
                        intent = new Intent(mContext, OvertimeActivity.class);
                        mContext.startActivity(intent);
                    }
                }
            }
        });
    }

    public void setChoice(int num) {
        this.num = num;
        notifyItemChanged(index);
    }
    public void setType(int type) {
        this.type = type;
    }
}
